<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发送微博</title>
</head>
<body>
<h1>分享照片</h1>
<form action="">
    <input type="text" name="content" placeholder="感想正文">
    <input type="file" name="picFile">
    <input type="button" value="发布" @click="send()">
</form>
<!--引入Vue和axios-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el:"form",
        data:{

        },
        methods:{
            send:function (){
                let data = new FormData(document.querySelector("form"))
                if (data.get("picFile").name == ""){
                    alert("请选择图片");
                    return;
                }
                axios.post("/juanzhou/insert",data).then(function (response){
                    if (response.data == 1){
                        location.href="/";
                    }else {
                        alert("请先登录")
                        location.href="/login.html"
                    }
                })
            }
        }

    })
</script>
</body>
</html>